lsiDict = {}
tfDict = {}
def Load(filePath,tDict):
    fopen = open(filePath, 'r')
    cow = -1
    for line in fopen:
        cow += 1
        line = line.split(':')[1]
        if line == '\n' or line == '':
            continue
        s = line.split(' ')
        tlist = []
        for i in s:
            if i == '\n':
                continue
            i = i.split(',')[0]
            tlist.append(i)
        tDict[cow] = tlist


silFile = "./vector/simsLsi.txt"
Load(silFile,lsiDict)
print(lsiDict)

tfFile = "./vector/sims.txt"
Load(tfFile,tfDict)
print(tfDict)

#两个dict对比
zq = 0
for key,num in enumerate(tfDict):
    try:
        lsiList = lsiDict[num]
        for i in tfDict[num]:
            if i in lsiList:
                zq += 1
    except KeyError:
        pass
print(zq)